<?php

class CommonController extends BaseController
{
    
    public function show($model,$id,$method,$url){
        if($method == 'show'){//显示数据，单个数据查询
            $data = $model::find($id);
            return Response::json($data);//$data;
        }else if($method == 'edit'){
            $item = $model::find($id);
            foreach (array_keys(Input::all()) as $key){
                $item->$key = Input::get($key);
            }
            $item->save();
            return Redirect::to($url);
        }else if($method == 'del'){
            $item = $model::find($id);
//             $model::delete($id);
            $item->delete();
            return Redirect::to($url);
        }else if ($method == 'add'){
            $item = new $model();
            foreach (array_keys(Input::all()) as $key){
                $item->$key = Input::get($key);
            }
            $item->save();
            return Redirect::to($url);
        }
        
    }
    
}

?>